const accessTokens = {
  admin: "admin-accessToken",
  editor: "editor-accessToken",
  test: "test-accessToken",
};

module.exports = [
    {
    url: "/user/login",
    type: "post",
    response(config) {
      const { username } = config.body;
      const accessToken = accessTokens[username];
      if (!accessToken) {
        return {
          code: 500,
          msg: "帐户或密码不正确。",
        };
      }
      return {
        code: 200,
        msg: "success",
        data: { accessToken },
      };
    },
  },
  {
    url: "/user/register",
    type: "post",
    response() {
      return {
        code: 200,
        msg: "模拟注册成功",
      };
    },
  },
  {
    url: "/user/info",
    type: "post",
    response(config) {
      const { accessToken } = config.body;
      let permissions = ["admin"],username = "admin";
      return {
        code: 200,
        msg: "success",
        data: {
          permissions,
          username,
          "avatar|1": [
            "http://pic.qqtn.com/file/2013/2014-5/2014052110011542660.gif",
            "http://www.2qqtouxiang.com/pic/TX4282_18.gif",
          ],
        },
      };
    },
  },
  {
    url: "/user/logout",
    type: "post",
    response() {
      return {
        code: 200,
        msg: "success",
      };
    },
  },
];
